package gui;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;

public class ResultTable extends JPanel {
	private JTable table;
	private String [][] daten;
	private String [] columns ={"Kunden Nr","Vorname","Nachname","Nachname", "Strasse", "PLZ","Stadt", "E-Mail", "Telefon", "Handy Nr", "Bank", "BLZ", "Konto Nr"};
	private DefaultTableModel myModel;
	private JPanel panel;
	/**
	 * Create the panel.
	 */
	public ResultTable() {
		
		JScrollPane scrollPane = new JScrollPane();
		
		panel = new JPanel();
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
						.addComponent(scrollPane, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 984, Short.MAX_VALUE)
						.addComponent(panel, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 870, GroupLayout.PREFERRED_SIZE))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 451, Short.MAX_VALUE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
					.addGap(23))
		);
		
		JButton btnAbbrechen = new JButton("Abbrechen");
		
		JButton btnLschen = new JButton("L\u00F6schen");
		
		JButton btnSpeichern = new JButton("Speichern");
		
		JButton btnBearbeiten = new JButton("Bearbeiten");
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup()
					.addContainerGap(486, Short.MAX_VALUE)
					.addComponent(btnAbbrechen)
					.addGap(18)
					.addComponent(btnLschen)
					.addGap(18)
					.addComponent(btnBearbeiten)
					.addGap(18)
					.addComponent(btnSpeichern)
					.addContainerGap())
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnSpeichern)
						.addComponent(btnBearbeiten)
						.addComponent(btnLschen)
						.addComponent(btnAbbrechen))
					.addContainerGap(3, Short.MAX_VALUE))
		);
		panel.setLayout(gl_panel);
		
		myModel= new DefaultTableModel(daten,columns){
			
			 @Override
			    public boolean isCellEditable(int row, int column) {
			       //all cells false
			       return false;
			    }
			};
			
		table = new JTable(myModel);
		scrollPane.setViewportView(table);
		setLayout(groupLayout);

	}
}
